@extends('layout.app') @section('content')

<div class="box-body">
    <div class="form-inline">

        <div class="form-group has-success">
            <input class="form-control" id="begin_time" placeholder="开始时间"/>
        </div>
        <div class="form-group has-success">
            <input class="form-control" id="end_time" placeholder="结束时间"/>
        </div>
        <div class="form-group has-success">
            &nbsp;<button id="button" class="btn btn-default" onclick="jQuery('#rowed3').setGridParam({postData: postData()}).trigger('reloadGrid')"><i class="fa fa-search"></i> 查询</button>
        </div>
        <div class="form-group has-success">
            &nbsp;<button id="button" class="btn btn-primary" onclick="setDate('<?php echo date("Y-m-d")?>', '')"> 本 日</button>
        </div>
        <div class="form-group has-success">
            &nbsp;<button id="button" class="btn btn-success" onclick="setDate('<?php echo date("Y-m-d", strtotime("Monday this week"))?>', '')"> 本 周</button>
        </div>
        <div class="form-group has-success">
            &nbsp;<button id="button" class="btn btn-info" onclick="setDate('<?php echo date("Y-m-d", strtotime("Monday this week")-604800)?>', '<?php echo date("Y-m-d", strtotime("last Sunday"))?>')"> 上 周</button>
        </div>
        <div class="form-group has-success">
            &nbsp;<button id="button" class="btn btn-warning" onclick="setDate('<?php echo date("Y-m-01")?>', '')"> 本 月</button>
        </div>
        <div class="form-group has-success">
            &nbsp;<button id="button" class="btn btn-danger" onclick="setDate('<?php echo date("Y-m-01",  strtotime(date("Y-m-01") . " -1 month"))?>', '<?php echo date("Y-m-d",  strtotime(date("Y-m-01") . " -1 day"))?>')"> 上 月</button>
        </div>
    </div>
    <div class="separator"></div>
    <table id="rowed3"></table>
    <div id="prowed3"></div>

</div>

<script>
    $(document).ready(function() {

        var data = {
            url: "/log/rmb",
            postData: postData(),
            colNames: [ '时间', '用户Id', '转账前余额', '转账后余额', '转账金额', '操作员' , '备注' , ''],
            colModel: [{
                name: 'create_time',
                search: false,
                formatter:'date',
                formatoptions: {srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s'},
                searchoptions: {
                    sopt: ['lt', 'le', 'gt', 'ge'],
                    dataInit : function (elem) {
                        $(elem).datepicker({
                            dateFormat: 'yy-mm-dd',
                            monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                            dayNamesMin: ['日','一','二','三','四','五','六'] });
                    }
                }
            }, {
                name: 'user_id'
            }, {
                name: 'before',
                search: false
            }, {
                name: 'after',
                search: false
            }, {
                name: 'rmb'
            }, {
                name: 'operator',
                sortable: false
            }, {
                name: 'desc',
                sortable: false,
                search: false
            }, {
                name: 'sum',
                hidden: true
            }],
            caption: '<i class="fa fa-table"></i> {{$label2}}',
            sortname: 'id',
            sortorder: "desc",
            gridComplete: function() {

                var sum = 0;
                if (($(this).getCol("sum").length)){

                    sum = $(this).getCol("sum")[0];
                }
                
                $(this).footerData("set", {

                    "count": "总计: <i class=\"fa fa-rub\"></i> " + sum
                });
            }
        };

        jqGrid(data);

        $(".form-inline .form-control").datepicker({
            dateFormat: 'yy-mm-dd',
            monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
            dayNamesMin: ['日','一','二','三','四','五','六'] });
    });

    function setDate(begin_time, end_time) {

        $("#begin_time").val(begin_time);
        $("#end_time").val(end_time);

        jQuery('#rowed3').setGridParam({postData: postData()}).trigger('reloadGrid')
    }

    function postData() {

        return {
            begin_time: $("#begin_time").val(),
            end_time: $("#end_time").val()
        }
    }
    
</script>

@endsection